package com.hl.util;

import java.util.List;

@SuppressWarnings("unchecked")
public class Pager {
	private List list;
	private int pageSize;
	private int pageCount;
	private int rowCount;
	private int curPage;
	private int curPageRowCount;

	public Pager(int pageSize, int curPage) {
		this.pageSize = pageSize;
		this.curPage = curPage;
	}

	public List getList() {
		return list;
	}

	public void setList(List list) {
		this.list = list;
	}

	public long getRowCount() {
		return rowCount;
	}

	public void setRowCount(int rowCount) {
		this.rowCount = rowCount;
		this.pageCount = rowCount % pageSize == 0 ? rowCount / pageSize : rowCount / pageSize + 1;
		// if (curPage < pageCount) {
		// this.curPageRowCount = pageSize;
		// } else {
		// this.curPageRowCount = (int) rowCount % pageSize;
		// }
		this.curPageRowCount = (curPage * pageSize > rowCount) ? rowCount : (curPage * pageSize);
	}

	public int getPageSize() {
		return pageSize;
	}

	public int getCurPage() {
		return curPage;
	}

	public int getPageCount() {
		return pageCount;
	}

	public int getCurPageRowCount() {
		return curPageRowCount;
	}

	public void setCurPage(int curPage) {
		this.curPage = curPage;
	}

	public void setCurPageRowCount(int curPageRowCount) {
		this.curPageRowCount = curPageRowCount;
	}

	public void setPageCount(int pageCount) {
		this.pageCount = pageCount;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

}
